Use case: CRC calculation with user configuration

This use case describes how to calculate a CRC with a user configuration using HAL1 and HAL2.

Sequence diagram

CRC calculation with user configuration (polling mode)

  @startuml

  == Initialization ==

  "Application"->"CRC" : HAL_CRC_Init()
  "CRC" --> "Application" : hal status : HAL_OK

  == Process : Polling mode ==

  "Application"->"CRC" :  HAL_CRC_Calculate
  "CRC" --> "Application": hal status : HAL_OK

  @enduml

Code snippet

HAL1

HAL2

HAL_CRC_Init(&hcrc);

uwCRCValue = HAL_CRC_Calculate(&hcrc,
                               (uint32_t *)&aDataBuffer,
                               BUFFER_SIZE);
HAL_CRC_Init(&hCRC, HAL_CRC);
HAL_CRC_SetConfig(&hCRC, &crc_config);
HAL_CRC_Calculate(pCRC,
                  &DataBuffer,
                  sizeof(uint32_t) * BUFFER_SIZE,
                  &CrcValue);

Key changes

  1. In HAL2, user configuration is applied through HAL_CRC_SetConfig() before starting the calculation.

  2. In HAL2, the CRC APIs can return additional statuses (for example HAL_INVALID_PARAM and HAL_BUSY).